package com.hpeng.daily.service.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.hpeng.daily.dao.AssetCardBookDao;
import com.hpeng.daily.service.AssetCardBookManager;
import com.hpeng.sys.model.AssetCard;
import com.hpeng.sys.model.AssetCardBook;
import com.hpeng.util.Pagination;

@Component("assetCardBookManager")
public class AssetCardBookManagerImpl implements AssetCardBookManager{
	
	@Resource
	private AssetCardBookDao assetCardBookDao;

	public Pagination<AssetCardBook> getPagination(String[] hql,
			Object[] values, int pageNumber) {
		return assetCardBookDao.getPagination(hql, values, pageNumber);
	}

	public AssetCardBook addAssetCardBook(AssetCardBook assetCardBook) {
		return assetCardBookDao.save(assetCardBook);
	}
	public void addAssetCardBook(AssetCard assetCard,String oprtStstus,String operator,String idea,String operatename) {
		// 在新录入资产时 同时向资产台帐里面插入数据
		for (int i = 0; i < Integer.parseInt(assetCard.getCount()); i++) {
			AssetCardBook book = new AssetCardBook();
			book.setCard(assetCard);
			book.setOperator(operator);
			book.setOperatedate(new Date());
			book.setOperatename(operatename);
			book.setAcprimarystatus(assetCard.getAcstatus().substring(0,1));
			book.setAcsecondstatus(assetCard.getAcstatus().substring(1));
			book.setOperatorStatus(oprtStstus);
			System.out.println("领导处理结果是："+idea);
			if(idea!=null){
				book.setCheckreason(idea);
				book.setDealreason(idea);
				book.setDealresult(idea);
			}
			addAssetCardBook(book);
		}
	}
}
